<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        /**
         *   `id` int(11) NOT NULL AUTO_INCREMENT,
            `name` varchar(50) NOT NULL COMMENT '分类名称',
            `topic_img_id` int(11) DEFAULT NULL COMMENT '外键，关联image表',
            `delete_time` int(11) DEFAULT NULL,
            `description` varchar(100) DEFAULT NULL COMMENT '描述',
            `update_time` int(11) DEFAULT NULL,
         */
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 50);
            $table->integer('topic_img_id')->unsigned();
            $table->string('description', 100);
            $table->foreign('topic_img_id')->references('id')->on('images')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('categories');
    }
}
